import { ConsoleDotColor, InfoLevel } from "@/engine/_";
import { CollapseToolbarItem } from "./types";
import { ActionKey } from "@/action/ActionKey";
import { controller } from "@/engine/Controller";

// log level color
export const ColorMap: { [key: string]: string } = {
  'DEBUG': '#21A1C7',
  'INFO': '#1F71C5',
  'WARN': '#E1AD00',
  'ERROR': '#D02A26'
};

// simulate features
export const CollapseCompList = [
  { title: 'control_panel', slotName: 'console' },
  { title: 'scene', slotName: 'scene' },
  { title: 'variable', slotName: 'operation' },
  { title: 'break_point', slotName: 'breakPoint' }
];

export const consoleToolbarItems: CollapseToolbarItem[] = [
  {
    label: 'clear',
    value: 'clearLog',
    actionKey: ActionKey.ClearLog,
    icon: 'statics/images/mainpage/iconclear.svg',
    notShowLabel: true,
  },
  {
    label: 'export',
    value: 'exportLog',
    actionKey: ActionKey.ExportLog,
    icon: 'statics/icons/app/iconexport.svg',
    notShowLabel: true,
  },
  {
    label: 'search',
    value: 'searchLog',
    actionKey: ActionKey.ShowLogSearch,
    icon: 'statics/images/mainpage/iconsearch.svg',
    notShowLabel: true,
    keepActive: true,
    get active() {
      return controller.consoleService.showSearch;
    }
  },
  {
    label: 'level',
    value: 'levelLog',
    actionKey: ActionKey.LevelLog,
    icon: 'statics/icons/simulation/iconaddfilter.svg',
    notShowLabel: true,
    keepActive: true,
    type: 'dropdown',
    // values: ['DEBUG', 'INFO', 'WARN', 'ERROR'],
    values: InfoLevel.INFO,
    showDot: true,
    dotColor: ConsoleDotColor[InfoLevel.INFO],
    children: [
      { label: 'debug', value: InfoLevel.DEBUG, icon: 'statics/icons/simulation/iconaddDebug.svg' },
      { label: 'info', value: InfoLevel.INFO, icon: 'statics/icons/simulation/iconaddInfo.svg' },
      { label: 'warning', value: InfoLevel.WARN, icon: 'statics/icons/simulation/iconaddWarn.svg' },
      { label: 'err', value: InfoLevel.ERROR, icon: 'statics/icons/simulation/iconaddError.svg' }
    ]
  }
];

export const sceneToolbarItems: CollapseToolbarItem[] = [
  {
    label: 'signalTrigger',
    actionKey: ActionKey.SceneSignalTrigger,
    icon: 'statics/icons/simulation/signalTrigger.svg',
    notShowLabel: true,
    get active() {
      return controller.sceneService.showTriggerBox && controller.toolbarService.signalList.length > 0;
    }
  },
];

export const variableToolbarItems: CollapseToolbarItem[] = [
  {
    label: 'export',
    actionKey: ActionKey.ExportVariable,
    icon: 'statics/icons/app/iconexport.svg',
    notShowLabel: true,
  },
  {
    label: 'showCol',
    actionKey: ActionKey.ShowVariableCol,
    icon: 'statics/icons/simulation/setting.svg',
    notShowLabel: true,
    type: 'dropdown-checkbox',
    // values: ['validationReq', 'reqContent'],
    children: [
      { label: '验证需求', value: 'validationReq' },
      { label: '需求内容', value: 'reqContent' },
    ],
  }
];

// debug breaks operate btns and tips
export const breakPointToolbarItems: CollapseToolbarItem[] = [
  {
    label: 'refresh',
    value: 'refreshFromModel',
    actionKey: ActionKey.RefreshFromModel,
    icon: 'statics/icons/simulation/iconfresh.svg',
    notShowLabel: true,
  },
  {
    label: 'delete',
    value: 'removeSelected',
    actionKey: ActionKey.RemoveSelected,
    icon: 'statics/icons/simulation/deleteRequirement.svg',
    notShowLabel: true,
  },
];
